# 构建go环境下的动态共享库
# 定义变量 project名称
project=cgoantpath
goantpath-version=v1.1.1

.PHONY: all clean wget build install goal

# 默认使用第一个真target，使用.DEFAULT_GOAL改变默认值
.DEFAULT_GOAL:= all

all: before wget build install clean
	@echo "all is execute."

before:
# 使用 ifeq不能有缩进
ifeq ($(GOROOT), )
	@echo "请注意！！！需要安装go编译环境。"
endif

wget: goal
	@echo "get from internet"

# 非linux平台编译linux共享库
build: goal
	@echo "convert to linux version"
	@xgo --targets=linux/amd64 -ldflags="-s -w" -buildmode=c-shared  gitee.com/greatwallmotor/go-antpath
	@mv ./go-antpath-linux-amd64.so ./lib${project}.so
# 增加执行权限
	@chmod g+x,u+x,o+x ./lib${project}.so

install: goal
	@echo "install application"

clean: goal
	@echo "clean successful"
	@rm -rf ./go-antpath-linux-amd64.h

